//
//  UIViewController+FlyElephant.m
//  SecondCarry
//
//  Created by 冯传昌 on 2020/5/27.
//  Copyright © 2020 Ny_MacBookPro. All rights reserved.
//

#import "UIViewController+FlyElephant.h"
#import <objc/runtime.h>

@implementation UIViewController (FlyElephant)
+(void)load {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        Class class = [self class];
        
        SEL originalSelector = @selector(viewDidAppear:);
        SEL swizzledSelector = @selector(fe_viewDidAppear:);
        
        Method originalMethod = class_getInstanceMethod(class, originalSelector);
        Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
        
        BOOL success = class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod));
        if (success) {
            class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
        } else {
            method_exchangeImplementations(originalMethod, swizzledMethod);
        }
    });
}
- (void)fe_viewDidAppear:(BOOL)animated {
        
    [self fe_viewDidAppear:animated];
    NSString * vc_name = NSStringFromClass([self class]);
    char tempChar[1000];
    NSString * tempString;
    strcpy(tempChar,(char *)[vc_name UTF8String]);
    printf("currentClassName=======---------    %s\n",tempChar);
}

@end
